class Gun:
    def __init__(self, mode1):
        # 枪支型号
        self.mode1 = mode1
        # 子弹数量
        self.bullet_count = 0

    def add_bullet(self, count):
        self.bullet_count += count

    def shoot(self):
        if self.bullet_count <= 0:
            print("empty fire")
            return
        self.bullet_count -= 1

        print("%s fire[%d]" % (self.mode1, self.bullet_count))


class Soldier:
    def __init__(self, name):
        self.name = name
        self.gun = None

    def fire(self):
        # 判断士兵是否有枪
        if self.gun is None:
            print("[%s]没有枪" % self.name)
            return

        print("冲啊[%s]" % self.name)
        self.gun.add_bullet(10)

        self.gun.shoot()


wappen = Gun("ak47")
tom = Soldier("tom")
tom.gun = wappen
tom.fire()
print(tom.gun)












